// const axios = require('../assets/js/axios')s
export const actions = {
  async nuxtServerInit(store, { app }) {
    console.log('nuxtServerInit')
    const { status: statusU, data: dataU } = await app.$axios.get('/user')
    store.dispatch(
      'user/setUser',
      statusU === 200 && dataU.code === 1 ? dataU.data : {}
    )
    const { status: statusC, data: dataC } = await app.$axios.get(
      `/classification/allClass`
    )
    store.commit(
      'classification/setAllClass',
      statusC === 200 && dataC.code === 1 ? dataC.data : []
    )
    const { status: statusUC, data: dataUC } = await app.$axios.get(
      `/classification/userClass`
    )
    store.commit(
      'classification/setUserClass',
      statusUC === 200 && dataUC.code === 1 ? dataUC.data : []
    )
    if (store.state.user.hasUser) {
      await store.dispatch('user/setDynamic', app.$axios)
    }
  }
}
